package com.ltkj.baseplatform.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import com.ltkj.baseplatform.domain.SerGuidedType;
import com.ltkj.baseplatform.service.ISerGuidedTypeService;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.utils.poi.ExcelUtil;
import com.ltkj.common.core.web.page.TableDataInfo;

/**
 * 导航导览分类Controller
 * 
 * @author chenzeen
 * @date 2023-09-10
 */
@Api(tags = "导航导览分类")
@RestController
@RequestMapping("/type")
public class SerGuidedTypeController extends BaseController
{
    @Autowired
    private ISerGuidedTypeService serGuidedTypeService;

    /**
     * 查询导航导览分类列表
     */
    @ApiOperation("查询导航导览分类列表")
    @GetMapping("/list")
    public TableDataInfo list(SerGuidedType serGuidedType)
    {
        startPage();
        List<SerGuidedType> list = serGuidedTypeService.selectSerGuidedTypeList(serGuidedType);
        return getDataTable(list);
    }

    /**
     * 导出导航导览分类列表
     */
    @ApiOperation("导出导航导览分类列表")
    @Log(title = "导航导览分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SerGuidedType serGuidedType)
    {
        List<SerGuidedType> list = serGuidedTypeService.selectSerGuidedTypeList(serGuidedType);
        ExcelUtil<SerGuidedType> util = new ExcelUtil<SerGuidedType>(SerGuidedType.class);
        util.exportExcel(response, list, "导航导览分类数据");
    }

    /**
     * 获取导航导览分类详细信息
     */
    @ApiOperation("获取导航导览分类详细信息")
    @GetMapping(value = "/{guidedTypeId}")
    public AjaxResult getInfo(@PathVariable("guidedTypeId") Long guidedTypeId)
    {
        return success(serGuidedTypeService.selectSerGuidedTypeByGuidedTypeId(guidedTypeId));
    }

    /**
     * 新增导航导览分类
     */
    @ApiOperation("新增导航导览分类")
    @RequiresPermissions("baseplatform:type:add")
    @Log(title = "导航导览分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SerGuidedType serGuidedType)
    {
        return toAjax(serGuidedTypeService.insertSerGuidedType(serGuidedType));
    }

    /**
     * 修改导航导览分类
     */
    @ApiOperation("修改导航导览分类")
    @RequiresPermissions("baseplatform:type:edit")
    @Log(title = "导航导览分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SerGuidedType serGuidedType)
    {
        return toAjax(serGuidedTypeService.updateSerGuidedType(serGuidedType));
    }

    /**
     * 删除导航导览分类
     */
    @ApiOperation("删除导航导览分类")
    @RequiresPermissions("baseplatform:type:remove")
    @Log(title = "导航导览分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guidedTypeIds}")
    public AjaxResult remove(@PathVariable Long[] guidedTypeIds)
    {
        return toAjax(serGuidedTypeService.deleteSerGuidedTypeByGuidedTypeIds(guidedTypeIds));
    }
}
